package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class SortListDemo2 {
    public static void main(String[] args) {
        List<Point> list = new ArrayList<>();
        list.add(new Point(1,2));
        list.add(new Point(12,22));
        list.add(new Point(3,9));
        list.add(new Point(8,8));
        list.add(new Point(7,6));
        list.add(new Point(19,36));
        list.add(new Point(5,4));
        System.out.println(list);



        Collections.sort(list,(o1,o2)->
                o1.getX()* o1.getX()+o1.getY()* o1.getY()
                        -
                o2.getX()* o2.getX() - o2.getY()* o2.getY());

        System.out.println(list);

    }
}






